<!DOCTYPE html>
<html lang="en">
	<head>
		<title> New Document </title>
		<meta charset="utf-8">
		<meta name="Author" content="">
		<meta name="Keywords" content="">
		<meta name="Description" content="">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<!-- Bootstrap -->
		<link href="${webRoot}resources/css/bootstrap.min.css" rel="stylesheet" media="screen">
		<link href="${webRoot}resources/css/style.css" rel="stylesheet">
		<script src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
		<style type="text/css">
		.black_overlay{
		display: none;
		position: absolute;
		top: 0%;
		left: 0%;
		width: 100%;
		height: 100%;
		background-color: black;
		z-index:1001;
		-moz-opacity: 0.8;
		opacity:.80;
		filter: alpha(opacity=80);
		}
		.white_content {
		display: none;
		position: absolute;
		top: 10%;
		left: 10%;
		width: 80%;
		height: 80%;
		border: 16px solid lightblue;
		background-color: white;
		z-index:1002;
		overflow: auto;
		}
		.white_content_small {
		display: none;
		position: absolute;
		top: 20%;
		left: 30%;
		width: 40%;
		height: 50%;
		border: 16px solid lightblue;
		background-color: white;
		z-index:1002;
		overflow: auto;
		}
	</style>
	</head>
<body class="main">
	<div class="wrap">
		<div class="">
		<ul class="breadcrumb">
		    <li><span id="test">您当前的位置：</span><a href="#">首页</a> <span class="divider">>></span></li>
		    <li class="active">${goodsList}</li>
	    </ul>
			<form class="form-inline">
				<input type="text" class="input-small" id="goodsName" placeholder="店铺名称">
				<select class="select" id="goodsStatus">
				    <option value="">所有</option>	
					<option value="E">可用</option>	
				    <option value="N">审核中</option>
				</select>			
				<button type="button" class="btn" onclick="serachHref();">搜索</button>
				<button type="button" class="btn" onclick="setNull();">重置</button>
			</form>
		</div>
		<div id ="div">
		<div class="">
			<table class="table table-bordered table-striped table-hover">
				<thead>
					<tr>
						<th>商铺名称</th>
						<th>联系电话</th>
						<th>地址</th>
						<th>经度</th>
						<th>纬度</th>
						<th>是否有团购</th>
						<th>添加时间</th>
						<th>推广</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody>
				<#if listGoodsEntity?exists>
				<#list listGoodsEntity as goodsEntity>
					<tr>
						<td>${goodsEntity.goods_Name}</td>
						<td>${goodsEntity.goods_telephone}</td>
						<td>${goodsEntity.goods_address}</td>
						<td>${goodsEntity.goods_Jingdu}</td>
						<td>${goodsEntity.goods_WeiDu}</td>
						<#if goodsEntity.goods_Isgroup == "Y">
						<td>是</td>
						<#else>
						<td>否</td>
						</#if>
						<td>${goodsEntity.goods_Date?string("yyyy-MM-dd")}</td>
						<#if goodsEntity.goods_Seq ==1>
						<td>第三位</td>
						<#elseif goodsEntity.goods_Seq ==2>
						<td>第二位</td>
						<#elseif goodsEntity.goods_Seq ==3>
						<td>第一位</td>
						<#else>
						<td>无</td>
						</#if>
						<#if goodsEntity.goods_Statu == "E">
						<td>可用</td>
						<#else>
						<td>审核中</td>
						</#if>
						<td>
						<#if userRole == "admin"|| userRole == "supAdmin">
						<#if goodsEntity.goods_Statu == "N">
						<a href="javascript:updateGoods(${goodsEntity.goods_id},'E')">审核</a>
						</#if>
						<#if goodsEntity.goods_Statu =="E">
						<a href="javascript:updateGoods(${goodsEntity.goods_id},'N')">撤销审核</a>
						</#if>
						</#if>
						<a href="javascript:selectOne(${goodsEntity.goods_id});">查看详情</a>
						<a href="javascript:updateGoodsInfo(${goodsEntity.goods_id})">修改</a>
						<#if userRole == "admin"|| userRole == "supAdmin">
						<a href="javascript:selectComment(${goodsEntity.goods_id})">查看点评</a>
						<a href="javascript:insertComment(${goodsEntity.goods_id},'${goodsEntity.goods_Name}')">添加点评</a>
						</#if>
						<a href="javascript:selectPic(${goodsEntity.goods_id})">查看图片</a>
						<a href="javascript:insertPice(${goodsEntity.goods_id},'${goodsEntity.goods_Name}')">上传图片</a>
						<a href="javascript:deleteGoods(${goodsEntity.goods_id},'${goodsEntity.goods_Isgroup}');">删除</a>
						<#if userRole == "admin"|| userRole == "supAdmin">
						<a href="javascript:sendGoods(${goodsEntity.goods_id},'${goodsEntity.goods_Name}')">推广</a>
						</#if>
						</td>
					</tr>
				</#list>
				<#else>
				   	 <tr>
				       <td colspan="9">没有查询到记录！</td>
				   </tr>
				</#if>
				</tbody>
			</table>			
		</div>
		<#if listGoodsEntity?exists>
		<div class="pagination pagination-right">
		  <input type="hidden" name="serchName" id="serchName" value="${serchName}"/>
		  <input type="hidden" name="serchStatus" id="serchStatus" value="${serchStatus}"/>
		  <ul>
		    <#if pageEntity.page==1>
		    <li class="disabled"><a href="#">&laquo;</a></li>
		    <#else>
		    <li><a href="javascript:pageHref(${pageEntity.page-1},${pageEntity.totalPage},${pageEntity.pageSize})">&laquo;</a></li>
		    </#if>
		    <#list 1..pageEntity.totalPage as i>
		         <#if pageEntity.page==i>
		    <li class="active"><a href="#">${i}</a></li>
		         <#else>
		    <li><a href="javascript:pageHref(${i},${pageEntity.totalPage},${pageEntity.pageSize})">${i}</a></li>
		        </#if>
		    </#list>
		   <#if pageEntity.page==pageEntity.totalPage>
		    <li class="disabled"><a href="#">»</a></li>
		    <#else>
		    <li><a href="javascript:pageHref(${pageEntity.page+1},${pageEntity.totalPage},${pageEntity.pageSize})">»</a></li>
		    </#if>
		  </ul>
		</div>
		</#if>
		</div>			
	</div>
	<form action="${webRoot}comment/addComment.do" method="post" id="insertComment">
	    <input type="hidden" id="goods_Id" name="goods_Id"/>
		<input type="hidden" id="goods_name" name="goods_name"/>
	</form>		
	<form action="${webRoot}pic/addPic.do" method="post" id="insertPic">
	    <input type="hidden" id="goods_id" name="goods_id"/>
		<input type="hidden" id="goods_name" name="goods_name"/>
	</form>	
	<form action="${webRoot}goods/sendGoods.do" method="post" id="sendGoods">
	    <input type="hidden" id="goodsId" name="goods_id"/>
		<input type="hidden" id="goods_Name" name="goods_Name"/>
	</form>	
	<!--弹出层时背景层DIV-->
<div id="fade" class="black_overlay">
</div>
<div id="MyDiv" class="white_content">
</div>	
	<script src="${webRoot}resources/js/bootstrap.min.js"></script>
	<script src="${webRoot}resources/js/js.js"></script>
	<script type="text/javascript">
	    function pageHref(page,totalPage,pageSize){
	    	var goodsName = escape(escape($("#serchName").val()));
			var goodsStatus = $("#serchStatus").val();
	    	$.ajax({url:"${webRoot}goods/goodsAjaxList.do?page="+page+"&pageSize="+pageSize+
	    			"&totalPage="+totalPage+"&goods_Name="+goodsName+"&goods_Statu="+goodsStatus,
				   type:"post",
				   cache:"false",
				   error : function() {
					   alert("系统繁忙，请稍后再试！");
					},
				   success:function(msg){
					   $("#div").html(msg);
				   }
				});
	    }
	    function serachHref(){
	    	var goodsName = escape(escape($("#goodsName").val()));
			var goodsStatus = $("#goodsStatus").val();
	    	$.ajax({url:"${webRoot}goods/goodsAjaxList.do?goods_Name="+goodsName+"&goods_Statu="+goodsStatus,
				   type:"post",
				   cache:"false",
				   error : function() {
					   alert("系统繁忙，请稍后再试！");
					},
				   success:function(msg){
					   $("#div").html(msg);
				   }
				});
	    }
	function deleteGoods(id,statu){
		var goodsName = escape(escape($("#serchName").val()));
		var goodsStatus = $("#serchStatus").val();
		if(statu=='Y'){
			if(confirm("该商铺下存在团购商品，删除该商铺的同时会删除该商铺下的团购商品，确定删除吗？")){
	    	$.ajax({url:"${webRoot}goods/deleteGoods.do?goods_id="+id+
	    			"&goods_Statu="+goodsStatus+"&goods_Name="+goodsName+"&goods_Isgroup="+statu,
				   type:"delete",
				   cache:"false",
				   error : function() {
					   alert("系统繁忙，请稍后再试！");
					},
				   success:function(msg){
					   $("#div").html(msg);
				   }
				});
			}
		}else if(statu=='N'){
			if(confirm("确定删除该商铺吗？")){
		    	$.ajax({url:"${webRoot}goods/deleteGoods.do?goods_id="+id+
		    			"&goods_Statu="+goodsStatus+"&goods_Name="+goodsName+"&goods_Isgroup="+statu,
					   type:"delete",
					   cache:"false",
					   error : function() {
						   alert("系统繁忙，请稍后再试！");
						},
					   success:function(msg){
						   $("#div").html(msg);
					   }
					});
				}
		}
	}
	
	function updateGoods(id,status){
		$("#goodsStatus").val("");
    	$.ajax({url:"${webRoot}goods/updateGoodsStatus.do?goods_id="+id+
			"&goods_Statu="+status,
			   type:"post",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#goodsStatus").val("");
				   $("#div").html(msg);
			   }
			});
	}
	
	function selectOne(id){
		$.ajax({url:"${webRoot}goods/selectOneGoods.do?goodsId="+id,
			   type:"get",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#MyDiv").html(msg);
				   ShowDiv('MyDiv','fade');
			   }
			});
	}
	
	function selectComment(id){
		$.ajax({url:"${webRoot}comment/getListComment.do?goods_Id="+id,
			   type:"get",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#MyDiv").html(msg);
				   ShowDiv('MyDiv','fade');
			   }
			});
	}
	
	function pageComment1(page,totalPage,pageSize){
		var goodsId = $("#goodsId").val();
    	$.ajax({url:"${webRoot}comment/getListComment.do?page="+page+"&pageSize="+pageSize+
    			"&totalPage="+totalPage+"&goods_Id="+goodsId,
			   type:"post",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#MyDiv").html(msg);
				   ShowDiv('MyDiv','fade');
			   }
			});
    }
	function deleteComment(commentId,goodsId){
			if(confirm("确定删除该点评吗？")){
		    	$.ajax({url:"${webRoot}comment/deleteComment.do?comment_Id="+commentId+
		    			"&goods_Id="+goodsId,
					   type:"delete",
					   cache:"false",
					   error : function() {
						   alert("系统繁忙，请稍后再试！");
						},
					   success:function(msg){
						   $("#MyDiv").html(msg);
						   ShowDiv('MyDiv','fade');
					   }
					});
				}
	}
	
	function updateGoodsInfo(id){
		window.location.href="${webRoot}goods/updateGoods.do?goodsId="+id
	}
	function setNull(){
		$("#goodsName").val("");
		$("#goodsStatus").val("");
	}
	
	function insertComment(id,name){
		$("#goods_Id").val(id);
		$("#goods_name").val(name);
		document.getElementById("insertComment").submit();
	}
	
	function insertPice(id,name){
		$("#goods_id").val(id);
		$("#goods_name").val(name);
		document.getElementById("insertPic").submit();
	}
	
	function sendGoods(id,name){
		$("#goodsId").val(id);
		$("#goods_Name").val(name);
		document.getElementById("sendGoods").submit();
	}
	function selectPic(id){
		$.ajax({url:"${webRoot}pic/getListPice.do?goods_id="+id,
			   type:"get",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#MyDiv").html(msg);
				   ShowDiv('MyDiv','fade');
			   }
			});
	}
	function pagePic(page,totalPage,pageSize){
		var picgoodsId = $("#picgoodsId").val();
    	$.ajax({url:"${webRoot}pic/getListPice.do?page="+page+"&pageSize="+pageSize+
    			"&totalPage="+totalPage+"&goods_id="+picgoodsId,
			   type:"post",
			   cache:"false",
			   error : function() {
				   alert("系统繁忙，请稍后再试！");
				},
			   success:function(msg){
				   $("#MyDiv").html(msg);
				   ShowDiv('MyDiv','fade');
			   }
			});
    }
	
	function deletePic(picId,goodsId){
		if(confirm("确定删除该图片吗？")){
	    	$.ajax({url:"${webRoot}pic/deletePic.do?pic_id="+picId+
	    			"&goods_id="+goodsId,
				   type:"delete",
				   cache:"false",
				   error : function() {
					   alert("系统繁忙，请稍后再试！");
					},
				   success:function(msg){
					   $("#MyDiv").html(msg);
					   ShowDiv('MyDiv','fade');
				   }
				});
			}
}
	//弹出隐藏层
	function ShowDiv(show_div,bg_div){
	document.getElementById(show_div).style.display='block';
	document.getElementById(bg_div).style.display='block' ;
	var bgdiv = document.getElementById(bg_div);
	bgdiv.style.width = document.body.scrollWidth;
	// bgdiv.style.height = $(document).height();
	$("#"+bg_div).height($(document).height());
	};
	//关闭弹出层
	function CloseDiv(show_div,bg_div)
	{
	document.getElementById(show_div).style.display='none';
	document.getElementById(bg_div).style.display='none';
	};
	</script>
</body>
</html>
